package com.hecore.lagou.work.sort;


import com.hecore.lagou.work.entity.SortNumBean;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * @Author: hecore
 * @Date: 2020/10/18 23:46
 * @Description: 排序Reducer 处理 输出参数采用 NullWritable,SortNumBean
 * SortNumBean已经结构化数据为制表符
 */

public class SortNumReducer extends Reducer<SortNumBean, NullWritable,NullWritable,SortNumBean> {

    /**
     * 重新reduce方法
     * @param key 自定义排序Bean
     * @param values 迭代器
     * @param context reducer上下文
     * @throws IOException
     * @throws InterruptedException
     */
    @Override
    protected void reduce(SortNumBean key, Iterable<NullWritable> values, Context context) throws IOException, InterruptedException {
        for (NullWritable value : values) {
            context.write(value, key);
        }
    }
}
